﻿Public Class Primitive

    Public p As New List(Of Point3d)

    Sub RotateX(ByVal a As Double)
        For Each p As Point3d In Me.p
            p.RotateX(a)
        Next
    End Sub

    Sub RotateY(ByVal a As Double)
        For Each p As Point3d In Me.p
            p.RotateY(a)
        Next
    End Sub

    Sub RotateZ(ByVal a As Double)
        For Each p As Point3d In Me.p
            p.RotateZ(a)
        Next
    End Sub

    Sub Offset(ByVal x As Double, ByVal y As Double, ByVal z As Double)
        For Each p As Point3d In Me.p
            p.Offset(x, y, z)
        Next
    End Sub

    ReadOnly Property Distance(ByVal p1 As Point3d) As Double
        Get
            If p.Count = 2 Then Return (New Point3d((p(0).x + p(1).x) / 2, (p(0).y + p(1).y) / 2, (p(0).z + p(1).z) / 2)).Distance(p1)
            Return (New Point3d((p(0).x + p(1).x + p(2).x) / 3, (p(0).y + p(1).y + p(2).y) / 3, (p(0).z + p(1).z + p(2).z) / 3)).Distance(p1)
        End Get
    End Property

End Class